/**
 * this class is for saving the Log on file.
 *
 */
package Log;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Date;

public class Log {
  public Log()
  {
	  String phrase="";
	    //open a file:
	    File aFile = new File("c:\\Log.txt");   
	    FileOutputStream outputFile = null;  
	    try {
	      outputFile = new FileOutputStream(aFile, true);
	    } catch (FileNotFoundException e) {
	      e.printStackTrace(System.err);
	    } 

	    FileChannel outChannel = outputFile.getChannel();
	    
	    ByteBuffer buf =  ByteBuffer.wrap(phrase.getBytes());

	    try {
	      outChannel.write(buf);
	      outputFile.close();
	    } catch (IOException e) {
	      e.printStackTrace(System.err);
	    }
  }
 
  public Log(String text) {
    String phrase = "\r\n"+text;
    Date timeArg=new Date();
    String timeString=timeArg.toString();
    phrase=phrase+" 	| 	Time: "+timeString+"\n";
    //open a file:
    File aFile = new File("c:\\Log.txt");   
    FileOutputStream outputFile = null;  
    try {
      outputFile = new FileOutputStream(aFile, true);
    } catch (FileNotFoundException e) {
      e.printStackTrace(System.err);
    } 

    FileChannel outChannel = outputFile.getChannel();
    
    ByteBuffer buf =  ByteBuffer.wrap(phrase.getBytes());

    try {
      outChannel.write(buf);
      outputFile.close();
    } catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }
}

